"""
核心功能函数模块
- 仅实现与 config.yaml 参数解耦的核心逻辑
"""

import os
from PIL import Image

def ensure_dir(path):
    if not os.path.exists(path):
        os.makedirs(path)

def save_figure(fig, filename, fig_dir="figures"):
    ensure_dir(fig_dir)
    path = os.path.join(fig_dir, filename)
    fig.savefig(path, dpi=300, bbox_inches='tight')
    print(f"图片已保存：{path}")
    return path

def show_all_images(image_paths):
    for path in image_paths:
        try:
            img = Image.open(path)
            img.show()
        except Exception as e:
            print(f"图片 {path} 打开失败：{e}")
